const getServerUrl = () => {
  if ("cordova" in window) {
    return 'http://' + window.localStorage.getItem('SERVER_IP') + ":9080";
  } else {
    return '';
  }
};

export const NATIVE_CLASS_PREFIX = "com.conyou.matryoshka.pda.ctrl.";

export const NATIVE_CLASS = {
  DeviceHandler: `${NATIVE_CLASS_PREFIX}DeviceHandler`,

  ProdInboundHandler: `${NATIVE_CLASS_PREFIX}ProdInboundHandler`,
  ProdInboundDetailsHandler: `${NATIVE_CLASS_PREFIX}ProdInboundDetailsHandler`,
  ProdInboundOpsHandler: `${NATIVE_CLASS_PREFIX}ProdInboundOpsHandler`,
  DataSyncHandler: `${NATIVE_CLASS_PREFIX}DataSyncHandler`,
  ProdMixInboundHandler: `${NATIVE_CLASS_PREFIX}ProdMixInboundHandler`,
  ProdMixInboundOpsHandler: `${NATIVE_CLASS_PREFIX}ProdMixInboundOpsHandler`,

  SaleOutboundHandler: `${NATIVE_CLASS_PREFIX}SaleOutboundHandler`,
  SaleOutboundDetailsHandler: `${NATIVE_CLASS_PREFIX}SaleOutboundDetailsHandler`,
  SaleOutboundOpsHandler: `${NATIVE_CLASS_PREFIX}SaleOutboundOpsHandler`,

  TmpPalletHandler: `${NATIVE_CLASS_PREFIX}TmpPalletHandler`,
  TmpPalletDetailsHandler: `${NATIVE_CLASS_PREFIX}TmpPalletDetailsHandler`,
  TmpPalletOpsHandler: `${NATIVE_CLASS_PREFIX}TmpPalletOpsHandler`,

  FrmPalletHandler: `${NATIVE_CLASS_PREFIX}FrmPalletHandler`,
  FrmPalletOpsHandler: `${NATIVE_CLASS_PREFIX}FrmPalletOpsHandler`,
  FrmPalletDetailsHandler: `${NATIVE_CLASS_PREFIX}FrmPalletDetailsHandler`,

  UnpackHandler: `${NATIVE_CLASS_PREFIX}UnpackHandler`,
  UnpackDetailsHandler: `${NATIVE_CLASS_PREFIX}UnpackDetailsHandler`,
  UnpackOpsHandler: `${NATIVE_CLASS_PREFIX}UnpackOpsHandler`,

  TransferInHandler: `${NATIVE_CLASS_PREFIX}TransferInHandler`,
  TransferInOpsHandler: `${NATIVE_CLASS_PREFIX}TransferInOpsHandler`,
  TransferInDetailsHandler: `${NATIVE_CLASS_PREFIX}TransferInDetailsHandler`,

  TransferOutHandler: `${NATIVE_CLASS_PREFIX}TransferOutHandler`,
  TransferOutOpsHandler: `${NATIVE_CLASS_PREFIX}TransferOutOpsHandler`,
  TransferOutDetailsHandler: `${NATIVE_CLASS_PREFIX}TransferOutDetailsHandler`,

  OtherInHandler: `${NATIVE_CLASS_PREFIX}OtherInHandler`,
  OtherInOpsHandler: `${NATIVE_CLASS_PREFIX}OtherInOpsHandler`,
  OtherInDetailsHandler: `${NATIVE_CLASS_PREFIX}OtherInDetailsHandler`,

  OtherOutHandler: `${NATIVE_CLASS_PREFIX}OtherOutHandler`,
  OtherOutOpsHandler: `${NATIVE_CLASS_PREFIX}OtherOutOpsHandler`,
  OtherOutDetailsHandler: `${NATIVE_CLASS_PREFIX}OtherOutDetailsHandler`,

  OrderMoveHandler: `${NATIVE_CLASS_PREFIX}OrderMoveHandler`,
  OrderMoveOpsHandler: `${NATIVE_CLASS_PREFIX}OrderMoveOpsHandler`,

  MoveDirectlyHandler: `${NATIVE_CLASS_PREFIX}MoveDirectlyHandler`,
  MoveDirectlyOpsHandler: `${NATIVE_CLASS_PREFIX}MoveDirectlyOpsHandler`,
  MoveDirectlyDetailsHandler: `${NATIVE_CLASS_PREFIX}MoveDirectlyDetailsHandler`,

  StocktakingHandler: `${NATIVE_CLASS_PREFIX}StocktakingHandler`,
  StocktakingOpsHandler: `${NATIVE_CLASS_PREFIX}StocktakingOpsHandler`,

  UserProfileHandler: `${NATIVE_CLASS_PREFIX}UserProfileHandler`,
};

export const SCAN_EVENT = "com.conyou.wms.SCAN_BARCODE";
export const BARCODE_PARSER = `${NATIVE_CLASS_PREFIX}BarcodeParseHandler`;

export const REQUIRED_RULE = [{ required: true, message: "此项必填!" }];

export const SERVICE_ID = {
  "MATRYOSHKA": "MATRYOSHKA",
  "DACHSHUND": "DACHSHUND"
};

export const CTX_PATH = {
  getMatryoshkaPrefix: () => getServerUrl() + '/matryoshka/api',
  getDachshundPrefix: () => getServerUrl() + '/dachshund/api'
};
export const SM4_KEY = "21015F2A379616895AAE3D7B6656ADF9";

export const RUM_CONTEXT = {
  "browserAgent": navigator.userAgent,
  "browserVendor": navigator.vendor,
  "platform": navigator.platform
};

// eslint-disable-next-line
export const PASSWORD_PATTERN = /^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[!@#$%^&*()_+\[\]{};':"\\|,.<>\/?-]).{8,}$/;
